<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,dsp.utils.*" errorPage="" %>
<%
request.setCharacterEncoding("GB2312");
%>
<jsp:useBean id="userinfo" scope="page" class="dsp.database.Operation"/>
<jsp:useBean id="user" scope="request" class="dsp.web.User"/>
<jsp:setProperty name="user" property="username" param="username"/>
<jsp:setProperty name="user" property="password" param="password"/>
<%
String sql = "";
ResultSet rs = null;
user.userLogin();
if(user.isStatus())
{	
	user.updateLevel();
	sql = "SELECT * FROM web_user WHERE username='"+request.getParameter("username")+"'";
	rs = userinfo.query(sql);
	rs.next();
	int logins = Integer.parseInt(rs.getString("logins")) +1;
	session.setAttribute("logins",String.valueOf(logins));
	session.setAttribute("lastlogin",rs.getString("lastlogin"));
	session.setAttribute("lastip",rs.getString("lastip"));
	
	sql = "UPDATE web_user SET logins=logins+1,lastlogin='"+GetDate.getStringDate()+"',lastip='"+request.getRemoteAddr()+"' WHERE username='"+request.getParameter("username")+"'";
	userinfo.update(sql);
	session.setAttribute("master", String.valueOf(user.findSubjectid()));
	session.setAttribute("username", user.getUsername());
	
	userinfo.closestmt();
	userinfo.closeconn();
	response.sendRedirect("index.jsp");
}
else
{	
	userinfo.closeconn();
	out.println("<script language=javascript> alert('"+ user.getMsg() + "'); location.href='login.jsp';</script>");	
}
%>
